package temp;

import java.util.Vector;

/**
 * @Description: 玩家的坦克
 * @CreateTime: 2024-01-25  15:00
 * @Author: JAMILA
 * @Version: 1.0
 */

public class Hero extends Tank {
    //玩家发射单颗子弹
    private Shot shot = null;
    //玩家发射多颗子弹
    private Vector<Shot> shots=new Vector<>();


    public Hero(int x, int y, int direct, int speed) {
        super(x, y, direct, speed);
    }

    public Vector<Shot> getShots() {
        return shots;
    }

    public void setShots(Vector<Shot> shots) {
        this.shots = shots;
    }


    //射击
    public void shotEnemyTank() {
        if (shots.size()==10){
            return;
        }
        //根据玩家坦克方向和炮口坐标创建子弹
        switch (getDirect()) {
            case 0: //向上
                shot = new Shot(getX() + 20, getY(), 0, 2);
                break;
            case 1: //向右
                shot = new Shot(getX() + 60, getY() + 20, 1, 2);
                break;
            case 2: //向下
                shot = new Shot(getX() + 20, getY() + 60, 2, 2);
                break;
            case 3: //向左
                shot = new Shot(getX(), getY() + 20, 3, 2);
                break;
        }
        //玩家发射多颗子弹
        shots.add(shot);
        //启动我们的Shot线程
        new Thread(shot).start();
    }

    public Shot getShot() {
        return shot;
    }

    public void setShot(Shot shot) {
        this.shot = shot;
    }
}
